home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 1 (Walnut Creek)
/
Aminet - June 1993 [Walnut Creek].iso
/
usenet
/
sources
/
volume90
/
aplictns
/
ifs_1_4
/
part03
< prev
Wrap
Text File
|
1990-03-06
|
26KB
|
776 lines
Path: xanth!cs.odu.edu!Amiga-Request
From: Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator)
Newsgroups: comp.sources.amiga
Subject: v90i102: IFS 1.4 - an iterated function system viewer, Part03/03
Message-ID: <11656@xanth.cs.odu.edu>
Date: 6 Mar 90 22:41:29 GMT
Sender: tadguy@cs.odu.edu
Reply-To: fullmer@alfalfa.sps.mot.com (Glen Fullmer)
Lines: 762
Approved: tadguy@cs.odu.edu (Tad Guy)
X-Mail-Submissions-To: Amiga@cs.odu.edu
X-Post-Discussions-To: comp.sys.amiga
Submitted-by: fullmer@alfalfa.sps.mot.com (Glen Fullmer)
Posting-number: Volume 90, Issue 102
Archive-name: applications/ifs-1.4/part03
#!/bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 3 (of 3)."
# Contents: source/ifsout.c
# Wrapped by tadguy@xanth on Tue Mar 6 17:38:08 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'source/ifsout.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'source/ifsout.c'\"
else
echo shar: Extracting \"'source/ifsout.c'\" \(23178 characters\)
sed "s/^X//" >'source/ifsout.c' <<'END_OF_FILE'
X/*
X*
X* IFSout.c - Iterated Function System
X* uses IFS to create a IFS-Construction Image
X* Released to the Public Domain - 1989 The Software Glen Company
X*
X*
X*/
X
X#include "standard.h"
X#include "ifs.h"
X#include "ifsout.h"
X#include "safeclose.h"
X
Xlong timeint;
Xshort gadcount;
Xfloat x=0., y=0.; /* the (real) x y before translation*/
XUWORD colortab[32];
Xint currentfun = 0;
Xint numoffun = 1; /* startout with two functions=numfun+1 */
Xchar fname[MAXFNLEN];
Xchar fn[MAXFNLEN/2];
Xchar fdir[MAXFNLEN/2] = ":ifs/coors";
Xshort vectorsw = FALSE,
X displaynumsw = TRUE,
X pausesw = FALSE,
X blackbacksw = TRUE,
X adjopen = FALSE;
X
XUSHORT mx, my; /* mouse location */
X
X/*****************
X** Main Program **
X*****************/
X
Xint main()
X{
X ULONG class;
X UWORD tempcolor;
X USHORT MenuNum, ItemNum, code;
X struct MenuItem *Item;
X APTR aAddress;
X
X short corner=0, adjdown = FALSE, boxmoved = FALSE;
X
X void graphit();
X void gadgetmessage();
X void initialit();
X void clearscreen();
X void setcolor();
X void setupgad();
X void closeout();
X void drawvectors();
X void autoadj();
X int closeby();
X void adjust();
X void displaynums();
X void getifsfun();
X void checkswitches();
X
X void putifsfun();
X
X/* default to small flower */
X float funs[FUNLIMIT][6] = { {0.20, 1.00, -0.65, 0.82, 1.11, 0.00},
X {0.40, 0.00, 0.30, -0.32, 0.32, 0.00}},
X percent[FUNLIMIT] = { 0.66, 1.00},
X xyscale = 0.11; /* could be .25; */
X
X int xoff = WIDTH/2 - 24,
X yoff = HEIGHT/2 + 28,
X i, j;
X
X initialit(funs,percent,&xyscale,&xoff,&yoff,¤tfun);
X
X FOREVER {
X
X if (pausesw) Wait((1 << w->UserPort->mp_SigBit) |
X (1 << adjwin->UserPort->mp_SigBit));
X if ((message = (struct IntuiMessage *)GetMsg(w->UserPort))) {
X class = message->Class;
X code = message->Code;
X mx = message->MouseX;
X my = message->MouseY;
X
X aAddress = message->IAddress;
X
X ReplyMsg(message); /* Can't reply until done using it! */
X switch (class) {
X case CLOSEWINDOW: /* Exit the program */
X if (adjopen)
X CloseWindowSafely(adjwin);
X closeout();
X exit(0);
X break;
X case MOUSEBUTTONS:
X if (code == SELECTDOWN) {
X if (vectorsw) {
X if (corner=closeby (funs, ¤tfun, numoffun, mx, my) )
X adjdown = TRUE;
X else
X if (numoffun > 0) currentfun = (currentfun + 1) %
X (numoffun + 1);
X }
X else setcolor();
X }
X else
X if (code == SELECTUP) {
X adjdown = FALSE;
X if (boxmoved) {
X clearscreen();
X boxmoved = FALSE;
X for (j=0;j<10;j++) /* settle in on function */
X graphit(funs,percent, xyscale, xoff, yoff, FALSE);
X }
X checkswitches(rp,funs,percent,currentfun,
X numoffun,vectorsw,displaynumsw);
X }
X setpots(adjwin, gads, PInfos, funs, percent, xyscale,
X xoff, yoff, currentfun, numoffun, stxt, adjopen);
X break;
X case INTUITICKS:
X if (adjdown) {
X boxmoved = TRUE;
X adjust(corner, rp, funs, currentfun, mx, my);
X }
X break;
X case MENUPICK:
X while (code != MENUNULL) {
X Item = (struct MenuItem *) ItemAddress(&Menu[0], code);
X MenuNum = MENUNUM( code );
X ItemNum = ITEMNUM( code );
X switch( MenuNum) {
X case 0: /* Project Menu */
X switch( ItemNum ) {
X case 0: /* About Menu */
X AutoRequest(w, &ReqText1, NULL,
X &OKIText, 10, 20, 310, 180);
X break;
X case 1: /* Save Current */
X if (get_fname(w,screen,"Save File",fn,fdir)
X != NULL) {
X fname[0] = '\0';
X strcat(fname,fdir);
X
X/* need to check if we need a / or not */
X if (fdir[strlen(fdir) - 1] != ':')
X strcat(fname,"/");
X
X strcat(fname,fn);
X putifsfun(fname,numoffun,funs,percent,
X colortab,xoff,yoff,xyscale);
X }
X checkswitches(rp,funs,percent,currentfun,
X numoffun,vectorsw,displaynumsw);
X break;
X case 2: /* Get IFS */
X if (get_fname(w,screen,"Get File",fn,fdir) != NULL) {
X fname[0] = '\0';
X strcat(fname,fdir);
X
X/* need to check if we need a / or not */
X if (fdir[strlen(fdir) - 1] != ':')
X strcat(fname,"/");
X strcat(fname,fn);
X getifsfun(fname,&numoffun,funs, percent,
X colortab,&xoff,&yoff,&xyscale);
X
X currentfun = 0;
X PInfos[0].HorizBody = FFFF/(numoffun+1);
X setpots(adjwin, gads, PInfos, funs, percent, xyscale,
X xoff, yoff, currentfun, numoffun, stxt, adjopen);
X for (j=0;j<10;j++) /* settle in on function */
X graphit(funs, percent, xyscale, xoff, yoff, FALSE);
X clearscreen();
X checkswitches(rp,funs,percent,currentfun,
X numoffun,vectorsw,displaynumsw);
X }
X break;
X case 3: /* To WB */
X ScreenToBack(screen);
X break;
X case 4: /* quit */
X if (adjopen)
X CloseWindowSafely(adjwin);
X closeout();
X exit(0);
X break;
X }
X break;
X case 1: /* Function Menu */
X switch( ItemNum ) {
X case 0: /* Zoom to Fit */
X x=0.; y=0.;
X autoadj(funs, percent, &xyscale, &xoff, &yoff, ¤tfun);
X clearscreen();
X checkswitches(rp,funs,percent,currentfun,
X numoffun,vectorsw,displaynumsw);
X break;
X case 1: /* Zoom out x 2 */
X xyscale = xyscale / 2;
X clearscreen();
X checkswitches(rp,funs,percent,currentfun,
X numoffun,vectorsw,displaynumsw);
X setpots(adjwin, gads, PInfos, funs, percent, xyscale,
X xoff, yoff, currentfun, numoffun, stxt, adjopen);
X break;
X case 2: /* Open adjust window in our new screen */
X if (!adjopen) {
X nadjwin.Screen = screen;
X adjwin = (struct Window *)OpenWindow(&nadjwin);
X if (adjwin == NULL) {
X closeout();
X exit(6);
X }
X adjopen = TRUE;
X setpots(adjwin, gads, PInfos, funs, percent, xyscale,
X xoff, yoff,currentfun, numoffun, stxt, adjopen);
X }
X else {
X WindowToFront(adjwin);
X }
X break;
X case 3: /* Another Function */
X if (numoffun < FUNLIMIT-1) {
X numoffun++;
X currentfun = numoffun;
X /* reset the new function */
X if(displaynumsw)
X clearscreen();
X funs[currentfun][0] = 1.;
X funs[currentfun][1] = 0.;
X funs[currentfun][2] = 0.;
X funs[currentfun][3] = 1.;
X funs[currentfun][4] = 0.;
X funs[currentfun][5] = 0.;
X adjpercent(numoffun, percent);
X setpots(adjwin, gads, PInfos, funs, percent, xyscale,
X xoff, yoff, currentfun, numoffun, stxt, adjopen);
X checkswitches(rp,funs,percent,currentfun,
X numoffun,vectorsw,displaynumsw);
X }
X break;
X case 4: /* Erase Current */
X if(numoffun > 1) {
X for (i=currentfun;i<numoffun;i++)
X for (j=0;j<6;j++)
X funs[i][j] = funs[i+1][j];
X funs[numoffun][0] = 1.;
X funs[numoffun][1] = 0.;
X funs[numoffun][2] = 0.;
X funs[numoffun][3] = 1.;
X funs[numoffun][4] = 0.;
X funs[numoffun][5] = 0.;
X percent[numoffun] = 0.;
X if (currentfun == numoffun) currentfun--;
X numoffun--;
X setpots(adjwin, gads, PInfos, funs, percent, xyscale,
X xoff, yoff, currentfun, numoffun, stxt, adjopen);
X clearscreen();
X checkswitches(rp,funs,percent,currentfun,
X numoffun,vectorsw,displaynumsw);
X }
X break;
X case 5: /* Erase All */
X numoffun = 1; /* Leave two */
X currentfun = 0;
X for (i=0;i<FUNLIMIT;i++) {
X funs[i][0] = 1.;
X funs[i][1] = 0.;
X funs[i][2] = 0.;
X funs[i][3] = 1.;
X funs[i][4] = 0.;
X funs[i][5] = 0.;
X percent[i] = 0.;
X }
X percent[0]=0.5; /* for the two left */
X percent[1]=1.;
X setpots(adjwin, gads, PInfos, funs, percent, xyscale,
X xoff, yoff, currentfun, numoffun, stxt, adjopen);
X clearscreen();
X checkswitches(rp,funs,percent,currentfun,
X numoffun,vectorsw,displaynumsw);
X break;
X } /* end of inner switch */
X
X break;
X case 2: /* Switches */
X switch( ItemNum ) {
X case 0: /* Toggle Boxes */
X if (vectorsw) {
X vectorsw = FALSE;
X clearscreen();
X }
X else {
X vectorsw = TRUE;
X }
X checkswitches(rp,funs,percent,currentfun,
X numoffun,vectorsw,displaynumsw);
X break;
X
X case 1: /* Toggle Numbers */
X if (displaynumsw) {
X displaynumsw = FALSE;
X clearscreen();
X if (vectorsw)
X drawvectors(rp, funs, numoffun, currentfun);
X }
X else {
X displaynumsw = TRUE;
X displaynums(rp, funs, percent, currentfun, numoffun);
X }
X break;
X
X case 2: /* Pause*/
X if (pausesw) {
X pausesw = FALSE;
X ModifyIDCMP(w,CLOSEWINDOW|MOUSEBUTTONS|MENUPICK|INTUITICKS);
X if(adjopen)
X ModifyIDCMP(adjwin,CLOSEWINDOW|GADGETUP);
X }
X else {
X pausesw = TRUE; /* set to only look at menupicks/close */
X ModifyIDCMP(w,CLOSEWINDOW|MENUPICK);
X if(adjopen)
X ModifyIDCMP(adjwin,CLOSEWINDOW);
X }
X break;
X case 3: /* Toggle Bk/Fg */
X if (blackbacksw) {
X blackbacksw = FALSE;
X }
X else {
X blackbacksw = TRUE;
X }
X tempcolor = colortab[0];
X colortab[0] = colortab[1];
X colortab[1] = tempcolor;
X LoadRGB4(ViewPortAddress(w), colortab, 16);
X break;
X } /* end of inner switch */
X } /* end of outer switch */
X code = Item->NextSelect;
X } /* end of if */
X break;
X } /* end of outer outer switch */
X } /* end of while */
X
X/* lets see if you want me to do something to adjwin */
X
X if (adjopen)
X if((message=(struct IntuiMessage *)GetMsg(adjwin->UserPort))) {
X class = message->Class;
X code = message->Code;
X aAddress = message->IAddress;
X ReplyMsg(message);
X switch (class) {
X case CLOSEWINDOW: /* Get rid of the requester */
X if (adjopen){
X CloseWindow(adjwin);
X adjopen = FALSE;
X }
X break;
X case GADGETUP: /*reply, then process */
X gadgetmessage(aAddress,adjwin,funs,percent,&xyscale,&xoff,&yoff,
X gads,PInfos,&numoffun,¤tfun,stxt,
X displaynumsw,adjopen);
X for (j=0;j<10;j++) /* settle in on function */
X graphit(funs, percent, xyscale, xoff, yoff, FALSE);
X checkswitches(rp,funs,percent,currentfun,
X numoffun,vectorsw,displaynumsw);
X break;
X } /* end switch */
X } /* end if */
X if(!adjdown)
X graphit(funs, percent, xyscale, xoff, yoff, TRUE);
X } /* end FOREVER */
X return(0);
X} /* end main */
X
Xvoid clearscreen() {
X
X SetAPen(rp,0);
X RectFill(rp, XSTART, YSTART-HEIGHT, WIDTH-XSTART, YSTART);
X}
X
Xvoid graphit(funs,percent,xyscale,xoff,yoff,drawit)
X
Xfloat funs[][6],percent[],xyscale;
Xint xoff,yoff,drawit;
X
X{
X double pk;
X int i, ix, iy, p;
X static int color;
X float newx, newy;
X
X p = rand();
X
X pk = p/(float) INT_MAX;
X
X i=0;
X
X while(i<numoffun && pk > percent[i]) {
X i++;
X }
X
X newx = funs[i][0] * x + funs[i][1] * y + funs[i][4];
X newy = funs[i][2] * x + funs[i][3] * y + funs[i][5];
X
X x = newx;
X y = newy;
X
X ix = x*HEIGHT*xyscale+xoff; /* Assumes that H<W */
X iy = y*HEIGHT*xyscale+yoff;
X
X if ((color = (i+2)%MAXCOLORS) < 2)
X color = color+2;
X if (drawit && ix>0 && ix<WIDTH && iy>0 && iy<HEIGHT) {
X SetAPen(rp, color);
X WritePixel(rp, ix, HEIGHT-iy);
X }
X}
X
Xvoid initialit (funs,percent,xyscale,xoff,yoff,currentfun)
X
Xfloat funs[][6],percent[],*xyscale;
Xint *xoff,*yoff,*currentfun;
X
X{
X int i;
X
X srand(time(&timeint)); /* Set Random Generator Seed */
X /* From Time */
X colortab[0] = 0;
X colortab[1] = 4095;
X
X GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0);
X if (GfxBase == NULL)
X exit(2);
X
X IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0);
X if (IntuitionBase == NULL) {
X CloseLibrary(GfxBase);
X exit(3);
X }
X
X
X screen = (struct Screen *)OpenScreen(&ns);
X if (screen == NULL) {
X CloseLibrary(IntuitionBase);
X CloseLibrary(GfxBase);
X exit(4);
X }
X
X nw.Screen = screen; /* Open window in our new screen */
X w = (struct Window *)OpenWindow(&nw);
X if (w == NULL) {
X CloseScreen(screen);
X CloseLibrary(IntuitionBase);
X CloseLibrary(GfxBase);
X exit(5);
X }
X
X setupgad();
X
X for (i=2;i<FUNLIMIT;i++) {
X funs[i][0] = 1.;
X funs[i][1] = 0.;
X funs[i][2] = 0.;
X funs[i][3] = 1.;
X funs[i][4] = 0.;
X funs[i][5] = 0.;
X percent[i] = 0.5;
X }
X
X setpots(adjwin, gads, PInfos, funs, percent, *xyscale, *xoff, *yoff,
X *currentfun, numoffun, stxt, adjopen);
X
X SetMenuStrip(w, &Menu[0]);
X ShowTitle(screen, FALSE); /* No Bars in Arizona */
X
X vp = &screen->ViewPort; /* Set colors in screen's VP */
X rp = w->RPort; /* Render into the window's RP */
X clearscreen();
X
X/* check and write indicators */
X checkswitches(rp,funs,percent,currentfun,numoffun,vectorsw,displaynumsw);
X
X/* Set the color registers */
X setcolor();
X
X/* default color for small flower */
X colortab[2] = 1404;
X colortab[3] = 3913;
X LoadRGB4(ViewPortAddress(w), colortab, 16);
X} /* end initialit */
X
Xvoid setcolor() {
X
X int i, colorinc;
X
X colorinc = rand() % 4096;
X
X colortab[2] = rand() % 4096;
X
X
X for (i=3; i<32; i++)
X colortab[i] = (colortab[i-1] + colorinc) % 4096;
X
X LoadRGB4(ViewPortAddress(w), colortab, 16);
X
X SetBPen(rp, 0); /* Insure clean text */
X
X}
X
Xvoid setupgad() {
X
X /* This is where the proportional gadgets are set up, using
X * the templates that were declared staticly.
X */
X short i,
X gadcount; /* index to next available Gadget */
X
X for(gadcount = 0; gadcount < NUMPROPS-2; gadcount++) {
X gads[gadcount] = TPropGadget;
X PInfos[gadcount] = TPropInfo;
X gads[gadcount].GadgetText = NULL; /* no text on prop gads */
X gads[gadcount].GadgetRender = (APTR)
X &PImages[gadcount];
X gads[gadcount].SpecialInfo = (APTR)&PInfos[gadcount];
X gads[gadcount].TopEdge = GADSIZE * (gadcount+2);
X if(gadcount != 0)
X gads[gadcount].NextGadget = &gads[gadcount-1];
X } /* end for */
X
X gads[NUMPROPS-2] = ZoomGadget;
X PInfos[NUMPROPS-2] = TPropInfo;
X PInfos[NUMPROPS-2].Flags = AUTOKNOB | FREEVERT;
X gads[NUMPROPS-2].SpecialInfo = (APTR)&PInfos[NUMPROPS-2];
X gads[NUMPROPS-2].GadgetRender = (APTR) &PImages[NUMPROPS-2];
X gads[NUMPROPS-2].NextGadget = &gads[NUMPROPS-3];
X
X gads[NUMPROPS-1] = CenterGadget;
X PInfos[NUMPROPS-1] = TPropInfo;
X PInfos[NUMPROPS-1].Flags = AUTOKNOB | FREEVERT | FREEHORIZ;
X gads[NUMPROPS-1].SpecialInfo = (APTR)&PInfos[NUMPROPS-1];
X gads[NUMPROPS-1].GadgetRender = (APTR) &PImages[NUMPROPS-1];
X gads[NUMPROPS-1].NextGadget = &gads[NUMPROPS-2];
X
X PInfos[0].HorizBody = FFFF/(numoffun+1);
X
X /* This is where the String gadgets are set up, using
X the templates that were declared staticly.
X */
X
X for(i=0; i<NUMSTRS; i++) {
X SInfo[i].Buffer = &stxt[i][0];
X SInfo[i].UndoBuffer = NULL;
X SInfo[i].BufferPos = 0;
X SInfo[i].MaxChars = GSTRLEN;
X SInfo[i].DispPos = 0;
X }
X
X for(gadcount = NUMPROPS; gadcount < NUMGADS; gadcount++) {
X gads[gadcount] = TStrngGadget;
X gads[gadcount].GadgetText =
X (struct IntuiText *) &StrngText[gadcount-NUMPROPS];
X gads[gadcount].GadgetRender = NULL;
X gads[gadcount].SpecialInfo = (APTR)&SInfo[gadcount-NUMPROPS];
X
X if(gadcount==NUMPROPS)
X gads[gadcount].TopEdge = 20;
X else
X gads[gadcount].TopEdge = GADSIZE * (gadcount+2-NUMPROPS);
X gads[gadcount].NextGadget = &gads[gadcount-1];
X } /* end for */
X} /* end setupgad */
X
Xvoid closeout() {
X
X ClearMenuStrip(w);
X CloseWindow(w);
X CloseScreen(screen);
X CloseLibrary(IntuitionBase);
X CloseLibrary(GfxBase);
X
X}
X
Xvoid displaynums(rp, funs, percent, currentfun, numoffun)
X struct RastPort *rp;
X float funs[][6], percent[];
X int currentfun, numoffun;
X{
X short i, j, k, color;
X char str[80];
X
X j = HEIGHT - (8*numoffun) - 10;
X Move(rp,0,j);
X
X for (i=0; i<=numoffun; i++) {
X if ((color = (i+2)%MAXCOLORS) < 2)
X color = color+2;
X SetAPen(rp, color);
X
X sprintf (str, "%3d ", i+1);
X Text(rp,str,strlen(str));
X for(k=0; k<6; k++) {
X sprintf (str, "%5.2f ", funs[i][k]);
X Text(rp,str,strlen(str));
X }
X sprintf (str, "%5.2f", ((i>0) ? percent[i]-percent[i-1] : percent[i]));
X Text(rp,str,strlen(str));
X j = j+8;
X Move(rp,0,j);
X }
X}
X
Xvoid autoadj(funs, percent, xyscale, xoff, yoff, currentfun)
X
Xfloat funs[][6],percent[],*xyscale;
Xint *xoff,*yoff,*currentfun;
X{
Xint j;
Xfloat minx = 1e20;
Xfloat miny = 1e20;
Xfloat maxx = -minx;
Xfloat maxy = -minx;
X
Xfor (j=0;j<100;j++)
X {graphit(funs, percent, *xyscale, *xoff, *yoff, FALSE);
X if (x < minx) minx = x;
X if (x > maxx) maxx = x;
X if (y < miny) miny = y;
X if (y > maxy) maxy = y;
X }
X
X if (maxx > minx && maxy > miny && minx > -1e20 && maxx < 1e20
X && miny > -1e20 && maxy < 1e20) { /* don't scale if either diff = 0 */
X
X if ( (maxx-minx)/WIDTH > (maxy-miny)/HEIGHT) {
X *xyscale = (SCRNSCALE*ASPECT)/ (maxx - minx);
X *xoff = (WIDTH>>1) * (1 - (SCRNSCALE*(maxx+minx)/(maxx-minx)));
X *yoff = (HEIGHT>>1) * (1 - (*xyscale * (maxy+miny)));
X }
X else {
X *xyscale = SCRNSCALE / (maxy - miny);
X *xoff = ((WIDTH - HEIGHT * *xyscale * (maxx-minx))/2.0) - (minx * HEIGHT * *xyscale);
X *yoff = (HEIGHT>>1) * (1 - SCRNSCALE - (2.0 * miny * *xyscale));
X }
X
X setpots(adjwin, gads, PInfos, funs, percent, *xyscale, *xoff, *yoff,
X *currentfun, numoffun, stxt, adjopen);
X
X }
X} /* end autoadj */
X
X
Xvoid getifsfun(fname,numoffun,funs,percent,colortab,xoff,yoff,xyscale)
X char fname[MAXFNLEN];
X int *numoffun;
X float funs[][6], percent[];
X UWORD colortab[];
X int *xoff,*yoff;
X float *xyscale;
X{
X FILE *fp;
X
X int tempcolor;
X int i, j;
X
X if ((fp = fopen(fname, "r")) == NULL) {
X printf("ifsout: can't open %s\n", fname);
X }
X else {
X fscanf(fp, "%d %d %d %f\n", numoffun, xoff, yoff, xyscale);
X for(i=0;i <= *numoffun;i++) {
X for(j=0; j<6; j++)
X fscanf(fp, "%f ", &funs[i][j]);
X fscanf(fp, "%f %d\n", &percent[i], &tempcolor);
X colortab[i+2] = (UWORD) tempcolor; /* assumes that i<= FUNLIMIT */
X }
X fclose(fp);
X LoadRGB4(ViewPortAddress(w), colortab, 16);
X }
X}
X
Xvoid putifsfun(fname,numoffun,funs,percent,colortab,xoff,yoff,xyscale)
X char fname[MAXFNLEN];
X int numoffun;
X float funs[][6], percent[];
X UWORD colortab[];
X int xoff,yoff;
X float xyscale;
X{
X FILE *fp;
X
X int i,j;
X
X if ((fp = fopen(fname, "w")) == NULL) {
X printf("ifsout: can't open %s for write\n", fname);
X }
X else {
X fprintf(fp, "%d %d %d %f\n", numoffun, xoff, yoff, xyscale);
X for(i=0;i<=numoffun;i++) {
X for(j=0; j<6; j++)
X fprintf(fp, "%5.2f ", funs[i][j]);
X /* assumes that FUNLIMIT <= 29 */
X fprintf(fp, " %5.2f %d\n", percent[i], colortab[i+2]);
X }
X }
X fclose(fp);
X
X}
X
X
X
END_OF_FILE
if test 23178 -ne `wc -c <'source/ifsout.c'`; then
echo shar: \"'source/ifsout.c'\" unpacked with wrong size!
fi
# end of 'source/ifsout.c'
fi
echo shar: End of archive 3 \(of 3\).
cp /dev/null ark3isdone
MISSING=""
for I in 1 2 3 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 3 archives.
rm -f ark[1-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0
--
Mail submissions (sources or binaries) to <amiga@cs.odu.edu>.
Mail comments to the moderator at <amiga-request@cs.odu.edu>.
Post requests for sources, and general discussion to comp.sys.amiga.